<template>
  <div class="search">
    <h4>整体</h4>
    <div class="box">
      <el-card class="box-card">
        <el-form ref="form" :model="form" :rules="rules" label-width="80px">
          <el-form-item label="活动名称" prop="name">
            <el-input v-model="form.name" style="width: 400px;"></el-input>
          </el-form-item>
          <el-form-item label="活动区域" prop="region">
            <el-select v-model="form.region" placeholder="请选择活动区域">
              <el-option label="区域一" value="shanghai"></el-option>
              <el-option label="区域二" value="beijing"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="活动时间" prop="date1">
            <el-col :span="11">
              <el-date-picker type="date" placeholder="选择日期" v-model="form.date1"
                style="width: 400px;"></el-date-picker>
            </el-col>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit('form')">立即创建</el-button>
            <el-button @click="resetForm('form')">重置</el-button>
          </el-form-item>
        </el-form>
      </el-card>
      <copy ref="copyText" :code="7"></copy>
    </div>
  </div>
</template>
  
<script>
import copy from '../../components/copy.vue'
export default {
  components: { copy },
  data() {
    return {
      code: "",
      //
      form: {
        name: '',
        region: '',
        date1: '',
      },
      rules: {
        name: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        region: [
          { required: true, message: '请选择活动资源', trigger: 'change' }
        ],
        date1: [
          { required: true, message: '请选择活动资源', trigger: 'change' }
        ]
      },
    }
  },
  created() {

  },
  methods: {
    onSubmit(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!');
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  }
}
</script>
  
<style lang="less" scoped>
@import './basic.less';
</style>
  
